/*
 * OSLOView.java
 */

package org.oslo.ui;

import application.Action;
import application.ResourceMap;
import application.SingleFrameApplication;
import application.FrameView;
import application.Task.BlockingScope;
import application.TaskMonitor;
import gov.nasa.worldwind.WWIcon;
import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.layers.IconLayer;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.util.Collection;
import java.util.List;
import javax.swing.Box;
import javax.swing.Timer;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import org.oslo.data.DataProvider;
import org.oslo.data.DataProviderFactory;
import org.oslo.domain.HotelInfo;
import org.oslo.domain.ImageInfo;
import org.oslo.domain.LocationInfo;
import org.oslo.sessioninfo.domain.SessionInfo;
import org.oslo.ui.util.HotelWWIcon;
import org.oslo.ui.util.ImageHelper;
import org.oslo.ui.util.SessionComboBoxModel.SessionLocationPair;
import org.oslo.ui.util.WorldWindSelectListener;
import org.oslo.ui.util.WorldWindUtil;

/**
 * The application's main frame.
 */
public class OSLOView extends FrameView {

    private static final String SESSION_ICON = "resources/images/it-duke.png";
    private static final String HOTEL_ICON = "resources/images/hotel-icon-small.gif";
    private static OSLOView instance = null;

    public static OSLOView getInstance() {
        return instance;
    }

    public List<SessionInfo> getSessions() {
        return sessionInfoList;
    }
    
    public void setSessions(List<SessionInfo> list) {
        sessionInfoList = list;
    }

    public OSLOView(SingleFrameApplication app) {
        super(app);
        instance = this;
        initComponents();
        jToolBar1.setVisible(false);
        initWorldwind();
        initDataProvider();

        // set flowlayout to center images
        jToolBar1.setLayout(new FlowLayout());

        // status bar initialization - message timeout, idle icon and busy animation, etc
        ResourceMap resourceMap = getResourceMap();
        int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
        messageTimer = new Timer(messageTimeout, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                statusMessageLabel.setText("");
            }
        });
        messageTimer.setRepeats(false);
        int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
        for (int i = 0; i < busyIcons.length; i++) {
            busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
        }
        busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
            }
        });
        idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
        statusAnimationLabel.setIcon(idleIcon);
        progressBar.setVisible(false);

        // connecting action tasks to status bar via TaskMonitor
        TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
        taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {

            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();
                if ("started".equals(propertyName)) {
                    if (!busyIconTimer.isRunning()) {
                        statusAnimationLabel.setIcon(busyIcons[0]);
                        busyIconIndex = 0;
                        busyIconTimer.start();
                    }
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(true);
                } else if ("done".equals(propertyName)) {
                    busyIconTimer.stop();
                    statusAnimationLabel.setIcon(idleIcon);
                    progressBar.setVisible(false);
                    progressBar.setValue(0);
                } else if ("message".equals(propertyName)) {
                    String text = (String) (evt.getNewValue());
                    statusMessageLabel.setText((text == null) ? "" : text);
                    messageTimer.restart();
                } else if ("progress".equals(propertyName)) {
                    int value = (Integer) (evt.getNewValue());
                    progressBar.setVisible(true);
                    progressBar.setIndeterminate(false);
                    progressBar.setValue(value);
                }
            }
        });

        // add a component listener to update some properties
        super.getFrame().addComponentListener(new ComponentListener() {

            public void componentResized(ComponentEvent e) {
            }

            public void componentMoved(ComponentEvent e) {
            }

            public void componentShown(ComponentEvent e) {
                // ugly way to make sure the size is set correctly
                e.getComponent().setSize(644, 600);
            }

            public void componentHidden(ComponentEvent e) {
            }
        });
    }

    public void addHotel(HotelInfo hotelInfo) {
        if (hotelButton.isSelected()) {
            WorldWindUtil.addHotelIcon(HOTEL_ICON, new LocationInfo(hotelInfo.getLongitude(), hotelInfo.getLatitude()), hotelInfo, iconlayer);    
            wwCanvas.repaint();
        }    
    }

    public void addImage(ImageInfo imageInfo) {
        if (photosButton.isSelected()) {
            ImageIcon icon = ImageHelper.createImageIcon(imageInfo.getImageData(), imageInfo.getDescription());
            ImageIcon small = new ImageIcon(ImageHelper.getScaledImage(icon.getImage(), 64, 64));
            ThumbnailAction action = new ThumbnailAction(icon, small, imageInfo.getDescription());

            System.out.println(jToolBar1.getComponentCount());
            jToolBar1.add(new JButton(action), jToolBar1.getComponentCount() - 1);            
           
        }
    }

    /**
     * Action that shows the about box
     */
    @application.Action
    public void showAboutBox(ActionEvent e) {
        if (aboutBox == null) {
            JFrame mainFrame = OSLOApp.getApplication().getMainFrame();
            aboutBox = new OSLOAboutBox(mainFrame);
            aboutBox.setLocationRelativeTo(mainFrame);
        }
        OSLOApp.getApplication().show(aboutBox);
    }

    /**
     * Action that loads in the images.
     */
    @application.Action
    public void loadImages() {
        Collection<WWIcon> icons = iconlayer.getIcons();
        WWIcon[] iconArray = icons.toArray(new WWIcon[icons.size()]);
        
        for (int i = 0; i < iconArray.length; i++) {
            if (iconArray[i] instanceof HotelWWIcon) {
                iconlayer.removeIcon(iconArray[i]);    
            }
        }


        if (hotelButton.isSelected()) {
            SessionLocationPair pair = (SessionLocationPair) comboSessions.getSelectedItem();
            try {
                List<HotelInfo> hotelInfo = provider.getHotels(pair.getName(), pair.getLocation());
                if (hotelInfo != null) {
                    for (HotelInfo hotelInfo1 : hotelInfo) {
                        WorldWindUtil.addHotelIcon(HOTEL_ICON, new LocationInfo(hotelInfo1.getLongitude(), hotelInfo1.getLatitude()), hotelInfo1, iconlayer);
                    }                    
                }
            } catch (Exception exception) {
                exception.printStackTrace();
            }
        }

        if (photosButton.isSelected()) {

            if (firstShow) {
                Dimension oldSize = super.getFrame().getSize();
                Dimension newSize = new Dimension(oldSize.width, oldSize.height + 80);

                super.getFrame().setSize(newSize);
                firstShow = false;
            }

            jToolBar1.removeAll();

            jToolBar1.add(Box.createGlue());
            jToolBar1.add(Box.createGlue());

            SessionLocationPair pair = (SessionLocationPair) comboSessions.getSelectedItem();
            try {
                // first load in all the images
                List<ImageInfo> info = provider.getSessionImages(pair.getName(), pair.getLocation());
                jToolBar1.setVisible(true);
                for (ImageInfo imageInfo : info) {
                    ImageIcon icon = ImageHelper.createImageIcon(imageInfo.getImageData(), imageInfo.getDescription());
                    ImageIcon small = new ImageIcon(ImageHelper.getScaledImage(icon.getImage(), 64, 64));
                    ThumbnailAction action = new ThumbnailAction(icon, small, imageInfo.getDescription());

                    System.out.println(jToolBar1.getComponentCount());
                    jToolBar1.add(new JButton(action), jToolBar1.getComponentCount() - 1);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            if (!firstShow) {
                Dimension oldSize = super.getFrame().getSize();
                Dimension newSize = new Dimension(oldSize.width, oldSize.height - 80);

                super.getFrame().setSize(newSize);
                firstShow = true;
            }
        }
        
        wwCanvas.repaint();
    }

    @application.Action
    public void searchConference() {
        sessionInfoList = null;
        Collection<WWIcon> icons = iconlayer.getIcons();
        WWIcon[] iconArray = icons.toArray(new WWIcon[icons.size()]);
        
        for (int i = 0; i < iconArray.length; i++) {
            iconlayer.removeIcon(iconArray[i]);
        }        
        
        SessionLocationPair pair = (SessionLocationPair) comboSessions.getSelectedItem();

        try {
            LocationInfo location = provider.getConferenceLocation(pair.getName(), pair.getLocation());
            
            if (location != null) {
                wwCanvas.getView().goToLatLon(LatLon.fromDegrees(location.getLatitude(), location.getLongitude()));
                WorldWindUtil.addIcon(SESSION_ICON, location, iconlayer);
                wwCanvas.repaint();                
            }
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    public void updateLocation(LocationInfo location) {
        System.out.println("sfdsf");
        wwCanvas.getView().goToLatLon(LatLon.fromDegrees(location.getLatitude(), location.getLongitude()));
        WorldWindUtil.addIcon(SESSION_ICON, location, iconlayer);
        wwCanvas.repaint();                
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents() {
        bindingContext = new javax.beans.binding.BindingContext();

        mainPanel = new javax.swing.JPanel();
        labelConf = new javax.swing.JLabel();
        labelAddress = new javax.swing.JLabel();
        comboSessions = new javax.swing.JComboBox();
        textAddress = new javax.swing.JTextField();
        buttonSearch = new javax.swing.JButton();
        hotelButton = new javax.swing.JRadioButton();
        photosButton = new javax.swing.JRadioButton();
        jSeparator1 = new javax.swing.JSeparator();
        buttonShow = new javax.swing.JButton();
        jToolBar1 = new javax.swing.JToolBar();
        jPanel1 = new javax.swing.JPanel();
        wwCanvas = new gov.nasa.worldwind.awt.WorldWindowGLCanvas();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
        statusPanel = new javax.swing.JPanel();
        javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
        statusMessageLabel = new javax.swing.JLabel();
        statusAnimationLabel = new javax.swing.JLabel();
        progressBar = new javax.swing.JProgressBar();

        mainPanel.setBorder(null);
        mainPanel.setMaximumSize(new java.awt.Dimension(500, 700));
        mainPanel.setMinimumSize(new java.awt.Dimension(500, 700));
        mainPanel.setPreferredSize(new java.awt.Dimension(500, 700));

        labelConf.setText(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getResourceMap(OSLOView.class).getString("labelConf.text")); // NOI18N

        labelAddress.setText(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getResourceMap(OSLOView.class).getString("labelAddress.text")); // NOI18N

        comboSessions.setModel(new org.oslo.ui.util.SessionComboBoxModel());
        comboSessions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ComboSessionChanged(evt);
            }
        });

        bindingContext.addBinding(comboSessions, "${model.selectedItem.location}", textAddress, "text");

        buttonSearch.setAction(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getActionMap(OSLOView.class, this).get("searchConference"));
        buttonSearch.setText(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getResourceMap(OSLOView.class).getString("buttonSearch.text")); // NOI18N

        hotelButton.setText(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getResourceMap(OSLOView.class).getString("hotelButton.text")); // NOI18N
        hotelButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));

        photosButton.setText(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getResourceMap(OSLOView.class).getString("photosButton.text")); // NOI18N
        photosButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));

        buttonShow.setAction(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getActionMap(OSLOView.class, this).get("loadImages"));
        buttonShow.setText(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getResourceMap(OSLOView.class).getString("buttonShow.text")); // NOI18N

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(wwCanvas, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 594, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(11, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(wwCanvas, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 360, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout mainPanelLayout = new org.jdesktop.layout.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jSeparator1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE)
            .add(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(jToolBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 615, Short.MAX_VALUE)
                .addContainerGap())
            .add(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(hotelButton)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(photosButton)
                        .add(18, 18, 18)
                        .add(buttonShow, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 63, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(mainPanelLayout.createSequentialGroup()
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(labelConf)
                            .add(labelAddress))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                            .add(textAddress)
                            .add(comboSessions, 0, 193, Short.MAX_VALUE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 276, Short.MAX_VALUE)
                        .add(buttonSearch)))
                .addContainerGap())
            .add(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(mainPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(labelConf)
                    .add(comboSessions, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(buttonSearch))
                .add(4, 4, 4)
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(labelAddress)
                    .add(textAddress, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jSeparator1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(mainPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(hotelButton)
                    .add(photosButton)
                    .add(buttonShow, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(1, 1, 1)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jToolBar1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(181, 181, 181))
        );

        fileMenu.setText(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getResourceMap(OSLOView.class).getString("fileMenu.text")); // NOI18N

        exitMenuItem.setAction(application.Application.getInstance(OSLOApp.class).getContext().getActionMap(OSLOView.class, this).get("quit"));
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getResourceMap(OSLOView.class).getString("helpMenu.text")); // NOI18N

        aboutMenuItem.setAction(application.Application.getInstance(org.oslo.ui.OSLOApp.class).getContext().getActionMap(OSLOView.class, this).get("showAboutBox"));
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        statusAnimationLabel.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);

        org.jdesktop.layout.GroupLayout statusPanelLayout = new org.jdesktop.layout.GroupLayout(statusPanel);
        statusPanel.setLayout(statusPanelLayout);
        statusPanelLayout.setHorizontalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 639, Short.MAX_VALUE)
            .add(statusPanelLayout.createSequentialGroup()
                .addContainerGap()
                .add(statusMessageLabel)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 453, Short.MAX_VALUE)
                .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(statusAnimationLabel)
                .addContainerGap())
        );
        statusPanelLayout.setVerticalGroup(
            statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(statusPanelLayout.createSequentialGroup()
                .add(statusPanelSeparator, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(statusPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(statusMessageLabel)
                    .add(statusAnimationLabel)
                    .add(progressBar, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(3, 3, 3))
        );

        setComponent(mainPanel);
        setMenuBar(menuBar);
        setStatusBar(statusPanel);

        bindingContext.bind();
    }// </editor-fold>//GEN-END:initComponents

private void ComboSessionChanged(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ComboSessionChanged
  // textAddress.setText(((SessionLocationPair)comboSessions.getModel().getSelectedItem()).getLocation());
}//GEN-LAST:event_ComboSessionChanged


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonSearch;
    private javax.swing.JButton buttonShow;
    private javax.swing.JComboBox comboSessions;
    private javax.swing.JRadioButton hotelButton;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JLabel labelAddress;
    private javax.swing.JLabel labelConf;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    private javax.swing.JRadioButton photosButton;
    private javax.swing.JProgressBar progressBar;
    private javax.swing.JLabel statusAnimationLabel;
    private javax.swing.JLabel statusMessageLabel;
    private javax.swing.JPanel statusPanel;
    private javax.swing.JTextField textAddress;
    private gov.nasa.worldwind.awt.WorldWindowGLCanvas wwCanvas;
    private javax.beans.binding.BindingContext bindingContext;
    // End of variables declaration//GEN-END:variables

    private final Timer messageTimer;
    private final Timer busyIconTimer;
    private final Icon idleIcon;
    private final Icon[] busyIcons = new Icon[15];
    private int busyIconIndex = 0;

    private JDialog aboutBox;
    private DataProvider provider;

    private void initDataProvider() {
      //provider = DataProviderFactory.getDataProvider(DataProviderFactory.DUMMY_PROVIDER);
      provider = DataProviderFactory.getDataProvider(DataProviderFactory.ESB_PROVIDER);       
    }

   private void initWorldwind() {
     WorldWindUtil.initModel(wwCanvas);
     iconlayer = WorldWindUtil.createIconLayer(wwCanvas);
     wwCanvas.addSelectListener(new WorldWindSelectListener());
   }
    private IconLayer iconlayer;
    private boolean firstShow = true;
    private List<SessionInfo> sessionInfoList;
   

}
